package com.hy.domain;

import javax.persistence.TypedQuery;
import javax.validation.constraints.Size;

import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Cases {

    @Size(min = 2)
    private String name;

    @Size(min = 2)
    private String image;
    
    @Size(max = 40000)
    private String link;
    
    private String keywords;
    
	private String description;
    
    public Cases prev() {
    	Cases obj = null;
    	try {
			TypedQuery<Cases> query = entityManager.createQuery("from Cases where id < :id order by id desc", Cases.class);
			query.setParameter("id", this.getId());
			query.setFirstResult(0).setMaxResults(1);
			obj = query.getSingleResult();
		} catch (Exception e) {
		}
    	return obj;
    }
    
    public Cases next() {
    	Cases obj = null;
    	try {
			TypedQuery<Cases> query = entityManager.createQuery("from Cases where id > :id order by id asc", Cases.class);
			query.setParameter("id", this.getId());
			query.setFirstResult(0).setMaxResults(1);
			obj = query.getSingleResult();
		} catch (Exception e) {
		}
    	return obj;
    }
}
